<template>
  <div class="dashboard">
    <div class="metric-container">
      <div class="metric" v-for="(metric, index) in metrics" :key="index">
        <div class="metric-icon">{{ metric.icon }}</div>
        <div class="metric-content">
          <h2>{{ metric.value }}</h2>
          <p>{{ metric.title }}</p>
          <p class="change">{{ metric.change }}</p>
        </div>
      </div>
    </div>
    <div class="chart-container">
      <h2>销售额</h2>
      <img src="@/assets/images/shuju.png" alt="销售额图表" />
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      metrics: [
        { title: '总销售额', value: '¥ 126560', change: '周同比 12.00% ▲ 日同比 11.00% ▼', icon: '💰' },
        { title: '订单量', value: '8846', change: '日订单量 123', icon: '📦' },
        { title: '支付笔数', value: '6560', change: '转化率 60%', icon: '💳' },
        { title: '运营活动效果', value: '78%', change: '周同比 12.00% ▲ 日同比 11.00% ▼', icon: '📈' }
      ],
    };
  },
};
</script>
<style scoped>
.dashboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background-color: #f5f5f5f5;
}

.metric-container {
  display: flex;
  justify-content: space-around;
  width: 100%;
  margin-bottom: 20px;
}

.metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin: 10px;
  width: 22%;
  text-align: center;
}

.metric-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

.metric-content h2 {
  font-size: 24px;
  margin: 0;
}

.metric-content p {
  font-size: 16px;
  margin: 5px 0;
}

.chart-container {
  width: 90%; /* Increased width to fill more space */
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 170, 0, 0.1);
  padding: 20px;
  text-align: center;
}

.chart-container img {
  width: 100%;
  max-height: 300px; /* Limit the height of the image */
  border-radius: 8px; /* Optional: Add border radius to the image */
  object-fit: contain; /* Ensure the image is not distorted */
}
</style>
